// pages/example/cacle/cacle.js
function getMonthDay(year, month) {
  return new Date(year, month, 0).getDate()
}

const tenMonth = [20,3000,1290,1,43235,123,547,658,679,78,0,98,765,413,42,5667,673,5664,256,6554,1,212,3,123,12,31,23,21,454,123]

Page({
  data: {
    nowMonth: 0,
    nowDate: null,
    nowDateMaxNumber: 0,
    tenMonth,
  },
  onLoad() {


    this.setData({
      weekData: ['日', "一", "二", "三", "四", "五", "六"],
      nowMonth: new Date().getMonth() + 1,
      nowYear: new Date().getFullYear(),
      nowDateMaxNumber: getMonthDay(new Date().getFullYear(), new Date().getMonth() + 1),
      // nowDate: (new Date().getFullYear() + "/") + (new Date().getMonth() + 1 + "/") + new Date().getDate()
      year: new Date().getFullYear(),
      month: new Date().getMonth() + 1,
      date: new Date().getDate(),
      nowDateString: String(new Date().getFullYear()) + String(new Date().getMonth() + 1),
      changeFullsString: "20231016"
    })
  },


  getNextMonthMaxNumber() {
    this.data.nowMonth++
    if (this.data.nowMonth > 12) {
      this.data.nowMonth = 1
      this.data.nowYear++
    }
    // get api
    

    // api -> month -> day
    this.setData({
      month:  this.data.nowMonth,
      year: this.data.nowYear,
      tenMonth: [12220,3000,1290,1,43235,123,547,658,679,78,0,98,765,413,42,5667,673,5664,256,6554,1,212,3,123,12,31,23,21,454,123],
      nowDateMaxNumber: getMonthDay(this.data.nowYear, this.data.nowMonth)
    })
  },
  getPrevMonthMaxNumber() {
    this.data.nowMonth--
    if (this.data.nowMonth < 1) {
      this.data.nowMonth = 12
      this.data.nowYear--
    }
    this.setData({
      month:  this.data.nowMonth,
      nowDateMaxNumber: getMonthDay(this.data.nowYear, this.data.nowMonth)
    })
  },



})